package skiree.host.abetsy.api.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import skiree.host.abetsy.api.service.CommentService;
import skiree.host.abetsy.api.vessel.Result;

import javax.annotation.Resource;

@Controller
@CrossOrigin
@RequestMapping("/api/private/v1")
public class CommentController {

    @Resource
    private CommentService commentService;

    @GetMapping("/comment/list")
    @ResponseBody
    public Result commentList(@RequestParam(required = false, defaultValue = "0") int episodeId,
                              @RequestParam(required = false, defaultValue = "") String query,
                              @RequestParam(required = false, defaultValue = "1") int pageNum,
                              @RequestParam(required = false, defaultValue = "9") int pageSize) {
        return commentService.list(episodeId, query, pageNum, pageSize);
    }

    @GetMapping("/comment/shows")
    @ResponseBody
    public Result commentShows(@RequestParam(required = false, defaultValue = "0") int episodeId) {
        return commentService.shows(episodeId);
    }

}
